package team3;

/**An AI that chooses moves based on an analysis of the current board state.
 * <p>
 * Specifically, the AI makes decisions based off a minmax tree analysis, using
 * an edge weighted board control goodness function, to a depth determined by
 * the AI's difficulty.
 */
public class AI extends project2.AI
{
    /**Builds an AI.
     * @param color The Player Color the AI represent
     * @param diff How hard the AI should try to win
     */
	public AI(Player color, Difficulty diff)
	{
		super(color, diff);
	}

	/** Determines the best move that can be made by analyzing a min max tree,
     * using a Weighted Board Control.
     * @param boardState Current state of the board
     * @param lastMove Move made by the enemy
     * @return A move, or BoardState.INVALID_MOVE if no good move is available.
     */
	public int[] makeMove(Player[][] boardState, int[] lastMove)
	{
        MinMaxTree decisionTree = new MinMaxTree(new BoardState(boardState), getPlayer());
        int[] move = decisionTree.getBestMove(getDepth(), new WeightedBoardControlGoodness());
        return move;
	}

    /** Calculates the depth at which a min max tree should be explored.
     * @return The depth to use with a min max tree
     */
    private int getDepth()
    {
        switch(getDifficulty())
        {
            case EASY : return 1;
            case MEDIUM : return 3;
            case HARD : return 4;
            default: return 1;
        }
    }
}
